//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for DeviceFarm
public struct DeviceFarmErrorType: AWSErrorType {
    enum Code: String {
        case argumentException = "ArgumentException"
        case cannotDeleteException = "CannotDeleteException"
        case idempotencyException = "IdempotencyException"
        case internalServiceException = "InternalServiceException"
        case invalidOperationException = "InvalidOperationException"
        case limitExceededException = "LimitExceededException"
        case notEligibleException = "NotEligibleException"
        case notFoundException = "NotFoundException"
        case serviceAccountException = "ServiceAccountException"
        case tagOperationException = "TagOperationException"
        case tagPolicyException = "TagPolicyException"
        case tooManyTagsException = "TooManyTagsException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize DeviceFarm
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// An invalid argument was specified.
    public static var argumentException: Self { .init(.argumentException) }
    /// The requested object could not be deleted.
    public static var cannotDeleteException: Self { .init(.cannotDeleteException) }
    /// An entity with the same name already exists.
    public static var idempotencyException: Self { .init(.idempotencyException) }
    /// An internal exception was raised in the service. Contact aws-devicefarm-support@amazon.com if you see this error.
    public static var internalServiceException: Self { .init(.internalServiceException) }
    /// There was an error with the update request, or you do not have sufficient permissions to update this VPC endpoint configuration.
    public static var invalidOperationException: Self { .init(.invalidOperationException) }
    /// A limit was exceeded.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// Exception gets thrown when a user is not eligible to perform the specified transaction.
    public static var notEligibleException: Self { .init(.notEligibleException) }
    /// The specified entity was not found.
    public static var notFoundException: Self { .init(.notFoundException) }
    /// There was a problem with the service account.
    public static var serviceAccountException: Self { .init(.serviceAccountException) }
    /// The operation was not successful. Try again.
    public static var tagOperationException: Self { .init(.tagOperationException) }
    /// The request doesn't comply with the AWS Identity and Access Management (IAM) tag policy. Correct your request and then retry it.
    public static var tagPolicyException: Self { .init(.tagPolicyException) }
    /// The list of tags on the repository is over the limit. The maximum number of tags that can be applied to a repository is 50.
    public static var tooManyTagsException: Self { .init(.tooManyTagsException) }
}

extension DeviceFarmErrorType: Equatable {
    public static func == (lhs: DeviceFarmErrorType, rhs: DeviceFarmErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension DeviceFarmErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
